#include <iostream>
#include <algorithm>
using namespace std;
const int N = 70;

int a;
int has[N];
int nex[N];
int ret;
int maxn, minn;
int n;
int cnt;
bool dfs(int limit, int count, int cur, int sum) {
	if (count == cnt) {
		return true;
	}
	if (limit == sum) {
		return dfs(limit, count + 1, maxn, 0);
	}
	if (sum + minn > limit)
		return false;
	for (int i = cur; i >= minn; i--) {
		if (sum + i <= limit && has[i]) {
			--has[i];
			if (dfs(limit, count, i, sum + i)) {
				return true;
			}
			++has[i];
			if (sum == 0 || sum + i == limit)
				return false;
		}
	}
	return false;
}
int main() {
	int sum = 0;
	cin >> n;
	minn = 51;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (a > 50)
			continue;

		sum += a;
		has[a]++;
		maxn = max(maxn, a);
		minn = min(minn, a);
	}

	int ret = -1;
	for (int i = maxn; i <= sum; i++) {
		while (sum % i != 0)
			++i;
		cnt = sum / i;
		if (dfs(i, 0, maxn, 0)) {
			ret = i;
			break;
		}
	}
	cout << ret << endl;
	return 0;
}
